/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


$(document).ready(function(){
    
    $("table.tablesorter").tablesorter(); 
     /********************FICHE PRODUIT***********/
    
    /*Galerie photos : plugin UI*/
    jQuery(function($){ 
 
      var settings = { 
        thumbListId: "thumbs", 
        imgViewerId: "viewer", 
        activeClass: "active", 
        activeTitle: "Photo en cours de visualisation", 
        loaderTitle: "Chargement en cours", 
        loaderImage: "../images/loader.gif" 
      }; 
      var thumbLinks = $("#"+settings.thumbListId).find("a"), 
        firstThumbLink = thumbLinks.eq(0), 
        highlight = function(elt){ 
          thumbLinks.removeClass(settings.activeClass).removeAttr("title"); 
          elt.addClass(settings.activeClass).attr("title",settings.activeTitle); 
        }, 
        loader = $(document.createElement("img")).attr({ 
          alt: settings.loaderTitle, 
          title: settings.loaderTitle, 
          src: settings.loaderImage 
        }); 
      highlight(firstThumbLink); 
      $("#"+settings.thumbListId).before( 
        $(document.createElement("p")) 
          .attr("id",settings.imgViewerId) 
          .append( 
            $(document.createElement("img")).attr({ 
              alt: "", 
              src: firstThumbLink.attr("href") 
            }) 
          ) 
      ); 

      var imgViewer = $("#"+settings.imgViewerId), bigPic = imgViewer.children("img"); 
      thumbLinks 
        .click(function(e){ 
          e.preventDefault(); 
          var $this = $(this), 
            target = $this.attr("href"); 
          if (bigPic.attr("src") == target) return; 
          highlight($this); 
          bigPic 
            .attr("src",target); 
        }); 
 
        });
       
        
        
        /*Accordeon en dessous de la fiche produit (Description,Videos,Commentaires et autres catégories */
        $(function() {
                var stop = false;
		$( "#accordion h3" ).click(function( event ) {
			if ( stop ) {
				event.stopImmediatePropagation();
				event.preventDefault();
				stop = false;
			}
		});
		$( "#accordion" )
			.accordion({
				header: "> div > h3"
			})
			.sortable({
				axis: "y",
				handle: "h3",
				stop: function() {
					stop = true;
				}
			});
                $(".ui-accordion-content").css('height','auto');
	});
    });
